package com.management.service.Impl;

import com.management.dao.PurchaseFormDao;
import com.management.po.PurchaseForm;
import com.management.service.PurchaseFormService;
import com.management.vo.PurchaseFormVO;


import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @category: 采购表业务逻辑实现类
 * @author: cwsheng
 * @version: 1.0
 * @date: 2021/10/31 0:12
 */
@Service
public class PurchaseFormServiceImpl implements PurchaseFormService {
    @Autowired
    PurchaseFormDao purchaseFormDao;

    @Override
    public List<PurchaseFormVO> findAll() {
        return purchaseFormDao.findAll();
    }

    @Override
    public List<PurchaseFormVO> findByCompanyId(int companyId) {
        return purchaseFormDao.findByCompanyId(companyId);
    }

    @Override
    public List<PurchaseFormVO> findByCompanyAndUserId(@Param("companyId") int companyId, @Param("userId") int userId) {
        return purchaseFormDao.findByCompanyAndUserId(companyId,userId);
    }

    @Override
    public List<PurchaseFormVO> findByMaterialsId(int materialsId) {
        return purchaseFormDao.findByMaterialsId(materialsId);
    }

    @Override
    public List<PurchaseFormVO> findByCompanyAndFormStatsId(@Param("companyId") int companyId,@Param("formStatsId") int formStatsId) {
        return purchaseFormDao.findByCompanyAndFormStatsId(companyId, formStatsId);
    }

    @Override
    public PurchaseFormVO findBy(String purchaseFormId) {
        return purchaseFormDao.findBy(purchaseFormId);
    }

    @Override
    public boolean add(PurchaseForm purchaseForm) {
        return purchaseFormDao.add(purchaseForm)>0?true:false;
    }

    @Override
    public boolean update(PurchaseForm purchaseForm) {
        return purchaseFormDao.update(purchaseForm)>0?true:false;
    }

    @Override
    public boolean delete(String purchaseFormId) {
        return purchaseFormDao.delete(purchaseFormId)>0?true:false;
    }
}
